<%@ page import="dao.IUsNewsDao" %>
<%@ page import="Impl.UsNewsDaoImpl" %>
<%@ page import="until.Newsgetto" %>
<%@ page import="java.util.List" %>
<%@ page import="entity.UsNews" %><%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2019/4/3
  Time: 18:10
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <title>main</title>
</head>
<body background="pic/ManBgroud.gif">
<%
    String Nindex = request.getParameter("pageindex");
    if (Nindex == null) {
        Nindex = "1";
    }
    int index = Integer.parseInt(Nindex);
    IUsNewsDao iud = new UsNewsDaoImpl();

    int count = iud.getCount();

    int tto = Newsgetto.getPageSize(count, Newsgetto.PageSize);

    if (index < 1) {
        index = 1;
    }
    if (index > tto) {
        index = tto;
    }
    List<UsNews> list = iud.showNews(Newsgetto.PageSize, index);


%>
<div style="margin: 0px auto;width: 600px">


    <table style="width: 400px" cellspacing="10" cellpadding="">

        <tr>
            <th>新闻主题</th>
            <th>发布时间</th>
        </tr>

        <%
            for (UsNews u : list) {
        %>

        <tr>
            <th>
                <%=u.getUsNewTitle()%>
            </th>
            <th>
                <%=u.getUsNewRiqi()%>
            </th>
        </tr>

        <%
            }
        %>
        <tr style="text-align: center">
            <td colspan="3">
                <a href="show_news.jsp?pageindex=1">首页</a>
                <a href="show_news.jsp?pageindex=<%=index-1%>">上一页</a>
                <a href="show_news.jsp?pageindex=<%=index+1%>">下一页</a>
                <a href="show_news.jsp?pageindex=<%=tto%>">尾页</a>
            </td>
        </tr>
    </table>
</div>
</body>
</html>
